package com.guoxin.principle.single;

/**
 * 单一职责原则
 *
 * @author guoxin
 * @date 2019/8/14
 */
public class SingleResponsibility3 {

    public static void main(String[] args) {
        Vehicle v = new Vehicle();
        v.runRoad("truck");
        v.runAir("plane");
        v.runWater("boat");
    }

    /**
     * 方式3的分析
     * 1.这种修改方法没有对原来的类做大的修改，只是增加方法
     * 2.这里虽然没有在类这个级别遵守单一职责原则，但是在方法级别上，仍然是遵守单一职责
     */
    private static class Vehicle {
        public void runRoad(String vehicle) {
            System.out.println(vehicle + " is running on the road");
        }

        public void runAir(String vehicle) {
            System.out.println(vehicle + " is running in the air");
        }

        public void runWater(String vehicle) {
            System.out.println(vehicle + " is running on the water");
        }
    }
}
